<template>
  <BasicModal
    width="700px"
    destroyOnClose
    @register="registerModal"
    v-bind="$attrs"
    title="提现详情"
  >
    <Description @register="registerDescription" />
  </BasicModal>
</template>
<script lang="ts" setup>
  import { BasicModal, useModalInner } from '@/components/Modal';
  import { Description, useDescription } from '@/components/Description';
  import { ref, h } from 'vue';
  import { QRCode, Tag } from 'ant-design-vue';
  import dayjs from 'dayjs';

  const info = ref();
  const statusText = ['等待审核', '审核中', '审核成功', '审核失败', '取消提现'];
  const [registerModal] = useModalInner((data) => {
    info.value = data;
  });
  const [registerDescription] = useDescription({
    bordered: true,
    column: 1,
    schema: [
      {
        field: 'orderNo',
        label: '申请提现代理账号',
      },
      {
        field: 'orderNo',
        label: '提现订单号',
      },
      {
        field: 'getTemId.type',
        label: '提现类型',
      },
      {
        field: 'amount',
        label: '申请提现金额',
      },
      {
        field: 'USDT',
        label: 'USDT汇率金额',
      },
      {
        field: 'getTemId.name',
        label: '提现申请收款姓名',
        render: (val, data) => {
          return data.getTemId.name;
        },
      },
      {
        field: 'getTemId.card',
        label: '提现申请收款账号/USDT币址',
        render: (val, data) => {
          return data.getTemId.card;
        },
      },
      {
        field: 'status',
        label: '提现申请状态',
        render: (val) => {
          return h(Tag, statusText[val]);
        },
      },
      {
        field: 'free',
        label: '手续费',
      },
      {
        field: 'userRemark',
        label: '备注内容',
      },
      {
        field: 'create_time',
        label: '订单创建时间',
        render: (val) => {
          return dayjs(val * 1000).format('YYYY-MM-DD HH:mm:ss');
        },
      },
      {
        field: 'back_time',
        label: '审核成功时间',
        render: (val) => {
          if (val) return dayjs(val * 1000).format('YYYY-MM-DD HH:mm:ss');
        },
      },
      {
        field: 'getTemId.qrcode',
        label: '收款二维码',
        render: (val, data) => {
          return h(QRCode, data.getTemId.qrcode);
        },
      },
      {
        field: 'mRemark',
        label: '拒绝原因',
      },
    ],
    data: info,
  });
</script>
